<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
</body>
</html>
<?php 
	/*
		@多个打包下载文件,并压缩。生成zip提供链接地址		
		@kang 
	*/
if(isset($_POST['down'])){
	require_once '../config.php';
	$id = $_POST['down_load'];	
    $path=array();
	foreach( $id as $value)
	{
		$query = $db_file->query("SELECT links FROM file WHERE file_id='$value'");
		$file_links=$db_file->fetch_array($query);
		array_push($path,$file_links['links']);
	}

	$zip = new ZipArchive;
	//$rename=$_POST['re'];
	$rename='../ui/zip/test';
	$down_name=$rename.".zip";
    foreach( $path as $value)
	{
		//echo $value."<br >";
		if ($zip->open($down_name, ZipArchive::CREATE) === TRUE)
		{
			$zip->addFile($value);//假设加入的文件名是image.txt，在当前路径下
			$zip->close();
		}
	}
	//echo "下载地址：".realpath($down_name);
}
	
	
?>
<a href="http://127.0.0.1/file_model/ui/zip/<?php echo basename($down_name); ?>" >下载</a>
